package com.woniuxy.carrental.controller;

import com.woniuxy.carrental.entity.PageBean;
import com.woniuxy.carrental.entity.ResponseResult;
import com.woniuxy.carrental.entity.Supply_car;
import com.woniuxy.carrental.mapper.Supply_carMapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author xilei
 * @create 2021-10-03 下午 8:03
 */
@RestController
public class SupplyCarController {
    @Resource
    Supply_carMapper supply_carMapper;

    @GetMapping("/supplycarlist0")
    public ResponseResult<PageBean<Supply_car>> getAllSupply_car(Integer pageIndex,Integer pageSize,Supply_car supply_car){
        System.out.println(supply_car);
        List<Supply_car> list = supply_carMapper.findSupply_carByPage(pageIndex, pageSize);
        for(Supply_car a:list){
            System.out.println(a);
        }
        PageBean<Supply_car> pageBean = new PageBean<>();
        pageBean.setPageSize(pageSize);
        pageBean.setPageIndex(pageIndex);
        pageBean.setTotalRecord(supply_carMapper.findSupply_car().size());
        pageBean.setBeanList(list);
        return new ResponseResult<>(pageBean, 200, "OK");
    }

    @GetMapping("/supplycarlist")
    public ResponseResult<PageBean<Supply_car>> getAllSupply_carBycar_id(Integer pageIndex,Integer pageSize){
        List<Supply_car> list = supply_carMapper.findSupply_carBycar_id(pageIndex, pageSize);
        for(Supply_car a:list){
            System.out.println(a);
        }
        PageBean<Supply_car> bean = new PageBean<>();
        bean.setPageIndex(pageIndex);
        bean.setPageSize(pageSize);
        bean.setBeanList(list);
        bean.setTotalRecord(supply_carMapper.findSupply_car().size());
        return new ResponseResult<>(bean, 200, "OK");
    }

    @GetMapping("/supplycarlist1")
    public ResponseResult<PageBean<Supply_car>> getAllSupply_carBy(Integer pageIndex,Integer pageSize,Integer car_id){
        System.out.println("输入查询的车辆ID为："+car_id);
        List<Supply_car> list = supply_carMapper.findSupply_carBy(pageIndex, pageSize, car_id);
        for(Supply_car b:list){
            System.out.println(b);
        }
        PageBean<Supply_car> bean = new PageBean<>();
        bean.setPageIndex(pageIndex);
        bean.setPageSize(pageSize);
        bean.setBeanList(list);
        bean.setTotalRecord(supply_carMapper.findSupply_car().size());
        return new ResponseResult<>(bean, 200, "OK");
    }
}
